package com.shiro;

import org.apache.shiro.web.filter.authc.BasicHttpAuthenticationFilter;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @Description:系统安全过滤器
 * @date: 2018/11/23 13:38
 */
public abstract class AbstractSecurityFilter extends BasicHttpAuthenticationFilter
{

    /**
     * 判断用户是否想要登录
     * 过滤器必须实现该方法
     *
     * @param request
     * @param response
     * @return
     */
    @Override
    protected abstract boolean isLoginAttempt(ServletRequest request, ServletResponse response);

    /**
     * 执行登录方法，过滤器必须实现该方法
     *
     * @param request
     * @param response
     * @return
     */
    @Override
    protected abstract boolean executeLogin(ServletRequest request, ServletResponse response);

    /**
     * 是否允许进入系统，过滤器比逊实现该方法
     *
     * @param request
     * @param response
     * @param mappedValue
     * @return
     */
    @Override
    protected abstract boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue);


}
